1//////////////////////////////////////////////////////////////////////
2// LibFile: nema_steppers.scad
3// Mounting holes for NEMA motors, and simple motor models.
4// Includes:
5// include <BOSL2/std.scad>
6// include <BOSL2/nema_steppers.scad>
7// FileGroup: Parts
8// FileSummary: NEMA motor mounts and stepper motor models.
9//////////////////////////////////////////////////////////////////////
10
11
12// Section: Motor Models
13
14
15// Module: nema_stepper_motor()
16// Synopsis: Creates a NEMA standard stepper motor model.
17// SynTags: Geom
18// Topics: Parts, Motors
19// See Also: nema_stepper_motor(), nema_mount_mask()
20// Usage:
21// nema_stepper_motor(size, h, shaft_len, [$slop=], ...) [ATTACHMENTS];
22// Description:
23// Creates a model of a NEMA standard stepper motor.
24// Arguments:
25// size = The NEMA standard size of the stepper motor.
26// h = Length of motor body. Default: 24mm
27// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 20mm
28// ---
29// details = If false, creates a very rough motor shape, suitable for using as a mask. Default: true
30// atype = The attachment set type to use when anchoring. Default: `"body"`
31// $slop = If details is false then increase size of the model by double this amount (for use as a mask)
32// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `TOP`
33// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
34// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
35// Anchor Types:
36// "shaft" = Anchor relative to the shaft.
37// "plinth" = Anchor relative to the plinth.
38// "body" = Anchor relative to the motor body.
39// "screws" = Anchor relative to the screw hole centers. ie: TOP+RIGHT+FRONT is the center-top of the front-right screwhole.
40// Examples:
41// nema_stepper_motor(size=8, h=24, shaft_len=15);
42// nema_stepper_motor(size=11, h=24, shaft_len=20);
43// nema_stepper_motor(size=17, h=40, shaft_len=30);
44// nema_stepper_motor(size=23, h=50, shaft_len=40);
45// nema_stepper_motor(size=23, h=50, shaft_len=40, details=false);
46module nema_stepper_motor(size=17, h=24, shaft_len=20, details=true, atype="body", anchor=TOP, spin=0, orient=UP)
47{
48 info = nema_motor_info(size);
49 motor_width = info[0];
50 plinth_height = info[1];
51 plinth_diam = info[2];
52 screw_spacing = info[3];
53 screw_size = info[4];
54 screw_depth = info[5];
55 shaft_diam = info[6];
56 geom = atype=="shaft"? attach_geom(r=shaft_diam/2, h=shaft_len-plinth_height, cp=[0,0,h/2+plinth_height/2+shaft_len/2]) :
57 atype=="plinth"? attach_geom(r=plinth_diam/2, h=plinth_height, cp=[0,0,h/2+plinth_height/2]) :
58 atype=="body"? attach_geom(size=[motor_width, motor_width, h]) :
59 atype=="screws"? attach_geom(size=[screw_spacing, screw_spacing, screw_depth], cp=[0,0,h/2-screw_depth/2]) :
60 assert(in_list(atype, ["shaft", "plinth", "body", "screws"]));
61 attachable(anchor,spin,orient, geom=geom) {
62 up(h/2) {
63 if (details == false) {
64 slop = get_slop();
65 color([0.4, 0.4, 0.4])
66 cuboid(size=[motor_width+2*slop, motor_width+2*slop, h+slop], anchor=TOP);
67 color([0.6, 0.6, 0.6])
68 cylinder(h=plinth_height+slop, d=plinth_diam+2*slop);
69 color("silver")
70 cylinder(h=shaft_len+slop, d=shaft_diam+2*slop, $fn=max(12,segs(shaft_diam/2)));
71 } else if (size < 23) {
72 difference() {
73 color([0.4, 0.4, 0.4])
74 cuboid(size=[motor_width, motor_width, h], chamfer=size>=8? 2 : 0.5, edges="Z", anchor=TOP);
75 color("silver")
76 xcopies(screw_spacing)
77 ycopies(screw_spacing)
78 cyl(r=screw_size/2, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
79 }
80 color([0.6, 0.6, 0.6]) {
81 difference() {
82 cylinder(h=plinth_height, d=plinth_diam);
83 cyl(h=plinth_height*3, d=shaft_diam+0.75);
84 }
85 }
86 color("silver") cylinder(h=shaft_len, d=shaft_diam, $fn=max(12,segs(shaft_diam/2)));
87 } else {
88 difference() {
89 union() {
90 color([0.4, 0.4, 0.4])
91 cuboid([motor_width, motor_width, h], rounding=screw_size, edges="Z", anchor=TOP);
92 color([0.6, 0.6, 0.6]) {
93 difference() {
94 cylinder(h=plinth_height, d=plinth_diam);
95 cyl(h=plinth_height*3, d=shaft_diam+0.75);
96 }
97 }
98 color("silver")
99 cylinder(h=shaft_len, d=shaft_diam, $fn=max(12,segs(shaft_diam/2)));
100 }
101 color([0.4, 0.4, 0.4]) {
102 xcopies(screw_spacing) {
103 ycopies(screw_spacing) {
104 cyl(d=screw_size, h=screw_depth*3, $fn=max(12,segs(screw_size/2)));
105 down(screw_depth) cuboid([screw_size*2, screw_size*2, h], anchor=TOP);
106 }
107 }
108 }
109 }
110 }
111 }
112 children();
113 }
114}
115
116
117
118// Section: Masking Modules
119
120
121// Module: nema_mount_mask()
122// Synopsis: Creates a standard NEMA mount holes mask.
123// SynTags: Geom
124// Topics: Parts, Motors
125// See Also: nema_stepper_motor(), nema_mount_mask()
126// Usage:
127// nema_mount_mask(size, depth, l, [$slop], ...);
128// Description: Creates a mask to use when making standard NEMA stepper motor mounts.
129// Arguments:
130// size = The standard NEMA motor size to make a mount for.
131// depth = The thickness of the mounting hole mask. Default: 5
132// l = The length of the slots, for making an adjustable motor mount. Default: 5
133// ---
134// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
135// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
136// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
137// $slop = The printer-specific slop value to make parts fit just right.
138// Anchor Types:
139// "full" = Anchor relative the full mask.
140// "screws" = Anchor relative to the screw hole centers. ie: TOP+RIGHT+FRONT is the center-top of the front-right screwhole.
141// Examples:
142// nema_mount_mask(size=14, depth=5, l=5);
143// nema_mount_mask(size=17, depth=5, l=5);
144// nema_mount_mask(size=17, depth=5, l=0);
145module nema_mount_mask(size, depth=5, l=5, atype="full", anchor=CENTER, spin=0, orient=UP)
146{
147 slop = get_slop();
148 info = nema_motor_info(size);
149 motor_width = info[0];
150 plinth_height = info[1];
151 plinth_diam = info[2] + slop;
152 screw_spacing = info[3];
153 screw_size = info[4] + slop;
154 screw_depth = info[5];
155 shaft_diam = info[6];
156 screwfn = quantup(max(8,segs(screw_size/2)),4);
157 plinthfn = quantup(max(8,segs(plinth_diam/2)),4);
158 s = atype=="full"? [screw_spacing+screw_size, screw_spacing+screw_size+l, depth] :
159 atype=="screws"? [screw_spacing, screw_spacing, depth] :
160 assert(in_list(atype, ["full", "screws"]));
161 attachable(anchor,spin,orient, size=s) {
162 union() {
163 xcopies(screw_spacing) {
164 ycopies(screw_spacing) {
165 if (l > 0) {
166 ycopies(l) cyl(h=depth, d=screw_size, $fn=screwfn);
167 cube([screw_size, l, depth], center=true);
168 } else {
169 cyl(h=depth, d=screw_size, $fn=screwfn);
170 }
171 }
172 }
173 if (l > 0) {
174 ycopies(l) cyl(h=depth, d=plinth_diam, $fn=plinthfn);
175 cube([plinth_diam, l, depth], center=true);
176 } else {
177 cyl(h=depth, d=plinth_diam, $fn=plinthfn);
178 }
179 }
180 children();
181 }
182}
183
184
185
186// Section: Functions
187
188
189// Function: nema_motor_info()
190// Synopsis: Returns dimension info for a given NEMA motor size.
191// Topics: Parts, Motors
192// See Also: nema_stepper_motor(), nema_mount_mask()
193// Usage:
194// info = nema_motor_info(size);
195// Description:
196// Gets various dimension info for a NEMA stepper motor of a specific size.
197// Returns a list of scalar values, containing, in order:
198// - MOTOR_WIDTH: The full width and length of the motor.
199// - PLINTH_HEIGHT: The height of the circular plinth on the face of the motor.
200// - PLINTH_DIAM: The diameter of the circular plinth on the face of the motor.
201// - SCREW_SPACING: The spacing between screwhole centers in both X and Y axes.
202// - SCREW_SIZE: The diameter of the screws.
203// - SCREW_DEPTH: The depth of the screwholes.
204// - SHAFT_DIAM: The diameter of the motor shaft.
205// Arguments:
206// size = The standard NEMA motor size.
207function nema_motor_info(size) =
208 let(
209 info_arr = [
210 [ 6, [ 14.0, 1.50, 11.0, 11.50, 1.6, 2.5, 4.00]],
211 [ 8, [ 20.3, 1.50, 16.0, 15.40, 2.0, 2.5, 4.00]],
212 [11, [ 28.2, 1.50, 22.0, 23.11, 2.6, 3.0, 5.00]],
213 [14, [ 35.2, 2.00, 22.0, 26.00, 3.0, 4.5, 5.00]],
214 [17, [ 42.3, 2.00, 22.0, 31.00, 3.0, 4.5, 5.00]],
215 [23, [ 57.0, 1.60, 38.1, 47.00, 5.1, 4.8, 6.35]],
216 [34, [ 86.0, 2.00, 73.0, 69.60, 6.5, 10.0, 14.00]],
217 [42, [110.0, 1.50, 55.5, 88.90, 8.5, 12.7, 19.00]],
218 ],
219 found = [for(info=info_arr) if(info[0]==size) info[1]]
220 )
221 assert(found, "Unsupported NEMA size.")
222 found[0];
223
224
225
226// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap